﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Demo1
{
    /// <summary>
    /// AddCalc1 的摘要说明
    /// </summary>
    public class AddCalc1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
          

            string hidden = context.Request["hidden"];

            string result = "";

            string num1 = "";

            string num2 = "";

            if (hidden == "yes")
            {

                num1 = context.Request["number1"];

                num2 = context.Request["number2"];

                result = (Convert.ToInt32(num1) + Convert.ToInt32(num2)).ToString();

            }

            string fullpath = context.Server.MapPath("AddCalc1.htm");

            string content = System.IO.File.ReadAllText(fullpath);

            content = content.Replace("@number1", num1);

            content = content.Replace("@number2", num2);

            content = content.Replace("@result", result);

            context.Response.Write(content);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}